﻿using UnityEngine;
using System.Collections;

public class GetAwardSphere : MonoBehaviour {

    public string weaponName;

    // 单手剑
    private GameObject singleSword;
    // 枪
    private GameObject gun;
    /// <summary>
    /// 双手剑
    /// </summary>
    private GameObject dualSword;

    public float Timer = 0;
    public bool BooTime;

    public AudioClip getSphereAudio;

	// Use this for initialization
	void Start () {

        singleSword = GameObject.Find("WeaponSingleSword");
        gun = GameObject.Find("WeaponGun");
        dualSword = GameObject.Find("WeaponDualSword");

        gun.SetActive(false);
        dualSword.SetActive(false);
        weaponName = "single";

	}
	
	// Update is called once per frame
	void Update () {

        if (BooTime)
        {
            Timer += Time.deltaTime;
        }

        if (Timer >= 7)
        {
            ReturnSingSword();
            Timer = 0;

        }

	}

    public void GetSphere(AwardType type)
    {
        AudioSource.PlayClipAtPoint(getSphereAudio, transform.position, 1.0f);

        if (type == AwardType.Gun)
        {
            ReturnGun();
        }
        else
            if (type == AwardType.DualSword)
            {
                ReturnDualSword();
            }
    }

    // 切换到枪
    void ReturnGun()
    {
        gun.SetActive(true);
        singleSword.SetActive(false);
        dualSword.SetActive(false);
        WeaponButtonChange.weaponButton.ReturnGunAttack();
        BooTime = true;
        Timer = 0;
        weaponName = "gun";

    }
    // 切换到双手剑
    void ReturnDualSword()
    {
        gun.SetActive(false);
        singleSword.SetActive(false);
        dualSword.SetActive(true);
        WeaponButtonChange.weaponButton.ReturnWeaponAttack();
        BooTime = true;
        Timer = 0;
        weaponName = "dual";
    }

    // 切换到单手剑
    void ReturnSingSword()
    {
        gun.SetActive(false);
        singleSword.SetActive(true);
        dualSword.SetActive(false);
        WeaponButtonChange.weaponButton.ReturnWeaponAttack();
        BooTime = false;
        weaponName = "single";
    }


}
